package com.bw.user.controller;

import com.bw.core.result.ResponseResult;
import com.bw.user.config.OSSBootUtil;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.HashMap;
import java.util.Map;

/**
 * @author admin
 */
@RestController
@RequestMapping("/oss")
@CrossOrigin
public class OssController {

    private final String UPLOADPATHLOAD = "upload/img/";

    @RequestMapping("/send")
    public Map<String,String> send(String id){
        HashMap<String, String> stringStringHashMap = new HashMap<>();
        stringStringHashMap.put("start","123");
        return stringStringHashMap;
    }

    @RequestMapping(value = "/uplImg" , method = RequestMethod.POST,consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    public ResponseResult uplImg(@RequestPart("file") MultipartFile file ){
        String upload = OSSBootUtil.upload(file, UPLOADPATHLOAD);
        return ResponseResult.success(upload);
    }
}
